// find min node <time, id>
// time += x;
// update node
//   erase, insert
// prioirty_queue /  set

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> ans(n);
  using pli = pair<long long, int>;
  set<pli> s;
  // priority_queue<pli, vector<pli>, greater<pli>> pq;
  for (int i = 0; i < n; i ++) {
    s.emplace(0, i);
  }
  for (int i = 1; i <= m; i ++) {
    int time;
    cin >> time;
    auto [total, id] = *s.begin();
    s.erase(s.begin());
    ans[id].push_back(i);
    s.emplace(total + time, id);
  }
  for (auto &line : ans) {
    if (line.size() == 0) {
      cout << "0" << endl;
      continue;
    }
    for (auto &x: line) {
      cout << x << ' ';
    }
    cout << endl;
  }
}